cmake_minimum_required(VERSION 2.8)

project(Mylib)

set(KIT ${PROJECT_NAME})

set(${KIT}_EXPORT_DIRECTIVE "${PROJECT_NAME}_EXPORTS")

set(MY_LIBRARY_EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE})
set(MY_EXPORT_HEADER_PREFIX ${KIT})
set(MY_LIBNAME ${KIT})

configure_file(ExportConfigure.h.in
               ${CMAKE_CURRENT_BINARY_DIR}/${MY_EXPORT_HEADER_PREFIX}Export.h)
               
add_library(${PROJECT_NAME} SHARED mylib.cxx include/mylib.h)

#SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/install)

target_include_directories(${PROJECT_NAME} PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "include/mylib.h;${CMAKE_CURRENT_BINARY_DIR}/${MY_EXPORT_HEADER_PREFIX}Export.h")

install(TARGETS ${PROJECT_NAME}
    EXPORT ${PROJECT_NAME}-targets
    PUBLIC_HEADER DESTINATION include
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin)

message(status "  mylib-targets: ${mylib-targets}")

install(EXPORT ${PROJECT_NAME}-targets
    NAMESPACE ${PROJECT_NAME}::
    FILE ${PROJECT_NAME}-config.cmake DESTINATION lib/cmake)
